package demo03;
/*
数组元素的反转：
本来的样子：{1,2,3,4}
之后的样子：{4,3,2,1}
 */
public class Demo07ArrayReverse {
    public static void main(String[] args) {
        int[] array={1,2,3,4};
        int temp;
        System.out.println("反转之前为：");
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i]);
        }
        System.out.println();

        //反转
        for (int i = 0; i < array.length/2; i++) {
            temp=array[i];
            array[i]=array[array.length-1-i];
            array[array.length-1-i]=temp;
        }

        System.out.println("反转之后为：");
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i]);
        }

    }
}
